// @ts-ignore
/* eslint-disable */
import request from "@/request";

/** addTeacher POST /api/teacher/add-teacher */
export async function addTeacherUsingPost(
  body: API.TeacherAddRequest,
  options?: { [key: string]: any }
) {
  return request<API.BaseResponseLong_>("/api/teacher/add-teacher", {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
    },
    data: body,
    ...(options || {}),
  });
}

/** getLoginUser GET /api/teacher/get/login */
export async function getLoginUserUsingGet(options?: { [key: string]: any }) {
  return request<API.BaseResponseLoginTeacherVO_>("/api/teacher/get/login", {
    method: "GET",
    ...(options || {}),
  });
}

/** importTeachers POST /api/teacher/import */
export async function importTeachersUsingPost(
  body: {},
  file?: File,
  options?: { [key: string]: any }
) {
  const formData = new FormData();

  if (file) {
    formData.append("file", file);
  }

  Object.keys(body).forEach((ele) => {
    const item = (body as any)[ele];

    if (item !== undefined && item !== null) {
      if (typeof item === "object" && !(item instanceof File)) {
        if (item instanceof Array) {
          item.forEach((f) => formData.append(ele, f || ""));
        } else {
          formData.append(ele, JSON.stringify(item));
        }
      } else {
        formData.append(ele, item);
      }
    }
  });

  return request<API.BaseResponseBoolean_>("/api/teacher/import", {
    method: "POST",
    data: formData,
    requestType: "form",
    ...(options || {}),
  });
}

/** getAllTeachersByPage GET /api/teacher/list */
export async function getAllTeachersByPageUsingGet(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.getAllTeachersByPageUsingGETParams,
  options?: { [key: string]: any }
) {
  return request<API.BaseResponsePage_>("/api/teacher/list", {
    method: "GET",
    params: {
      // pageNum has a default value: 1
      pageNum: "1",
      // pageSize has a default value: 10
      pageSize: "10",
      ...params,
    },
    ...(options || {}),
  });
}

/** userLogin POST /api/teacher/login */
export async function userLoginUsingPost(
  body: API.TeacherLoginRequest,
  options?: { [key: string]: any }
) {
  return request<API.BaseResponseLoginTeacherVO_>("/api/teacher/login", {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
    },
    data: body,
    ...(options || {}),
  });
}

/** userLogout POST /api/teacher/logout */
export async function userLogoutUsingPost(options?: { [key: string]: any }) {
  return request<API.BaseResponseBoolean_>("/api/teacher/logout", {
    method: "POST",
    ...(options || {}),
  });
}

/** register POST /api/teacher/register */
export async function registerUsingPost(
  body: API.TeacherRegisterRequest,
  options?: { [key: string]: any }
) {
  return request<API.BaseResponseLong_>("/api/teacher/register", {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
    },
    data: body,
    ...(options || {}),
  });
}

/** sendVerificationEmail POST /api/teacher/send-verification */
export async function sendVerificationEmailUsingPost(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.sendVerificationEmailUsingPOSTParams,
  options?: { [key: string]: any }
) {
  return request<API.BaseResponseLong_>("/api/teacher/send-verification", {
    method: "POST",
    params: {
      ...params,
    },
    ...(options || {}),
  });
}
